Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

184
Vistas
react-lazy-load-image-component Getting Error "TypeError: Cannot read properties of undefined (reading 'prototype')"

I'm using the React Testing Library, and when the component I'm rendering contains a LazyLoadImage from "react-lazy-load-image-component" I get the error "TypeError: Cannot read properties of undefined (reading 'prototype')".

Here's a picture of the error I got:

enter image description here

And this is the image of the code snippet in the component that I rendered:

enter image description here

If anyone is experiencing the same thing as me and has found a solution I really appreciate it. Thank you

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I was having the similar kind of error ( Not exactly the same ) and resolved by changing few things.

  1. You are planning of assigning the value to src of LazyloadImage component only if :
    a. It contains image which is inside of meta ( which is intern inside of article ) and you are not sure that all the time these parameters be present.

  2. You have added a logical and condition to check the presence of each element in hierarchy so that there won't be an issue of cannot find an element of undefined

  3. The main thing is what if any of that condition block falls on false condition ?

At that time, your image tag receive src as false ( src accepts the string not boolean )

so,

Instead of <LazyLoadImage src={article && article.meta && article.meta.image} >

use : {article && article.meta && article.meta.image && <LazyLoadImage src={article.meta.image} >}

This will check the existence of src before compiling to the browser.

Hope this helps!

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda